﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using eTerm.ASynClientSDK.Base;
using System.Text.RegularExpressions;

namespace eTerm.ASynClientSDK
{
    /// <summary>
    /// 清Q起始指令
    /// </summary>
    public sealed class QTCommand : ASynCommand
    {
        private const string m_Command = @"SR";
        /// <summary>
        /// 分析结果
        /// </summary>
        /// <param name="Msg"></param>
        /// <returns></returns>
        protected override ASyncResult ResultAdapter(string Msg)
        {
            QTResult Result = new QTResult();
            Match m = Regex.Match(Msg, m_Command + @"\s+(\d{4})\s+\d{4}", RegexOptions.Multiline | RegexOptions.IgnoreCase);
            Result.ExistQ =!m.Success?false: !(m.Groups[1].Value == @"0000");
            return Result;
        }

        /// <summary>
        /// 开始清Q
        /// </summary>
        public ASyncResult Execute() {
            return base.GetSyncResult(@"QT");
        }
    }
}
